package com.examples;

import toman.Index;
import toman.Prop;
import toman.orm.TO;

/**
 * User: zslajchrt
 * Date: 30.4.11
 * Time: 18:36
 */
@FilterType(PhotoFilter.class)
@TO(
    id = "p.id=:photoId",
    read = "select p.id, p.name, p.description, p.album.name from Photo p",
    write = "update Photo p set p.name=:photoName, p.description=:photoDescription")
public class SimplePhotoTO {
    @Index(0)
    @Prop
    private int photoId;
    @Index(1)
    @Prop
    private String photoName;
    @Index(3)
    @Prop("ALBUM_NAME")
    private String albumName;

    private String photoDescription;

    @Index(2)
    @Prop
    public void setPhotoDescription(String photoDescription) {
        this.photoDescription =
                photoDescription == null || "".equals(photoDescription) ? "N/A" : photoDescription;
    }

    public String getPhotoDescription() {
        return photoDescription;
    }

    public int getPhotoId() {
        return photoId;
    }

    public void setPhotoId(int photoId) {
        this.photoId = photoId;
    }

    public String getPhotoName() {
        return photoName;
    }

    public void setPhotoName(String photoName) {
        this.photoName = photoName;
    }

    public String getAlbumName() {
        return albumName;
    }

    public void setAlbumName(String albumName) {
        this.albumName = albumName;
    }
}
